import {baseRequest} from '@/utils/request'

const request = (url, ...arg) => baseRequest(`/process/datasource/` + url, ...arg)

export default {
	async save(data) {
		return await request('save', data, 'post')
	},
	// 获取代码生成基础分页
	async queryDbTypeList() {
		return await request('db_type_list', {}, 'post')
	},
	async queryList() {
		return await request('list', {}, 'post')
	},
	async getUrl(data) {
		return await request('get_url', data, 'post')
	},
	async setStatusFlag(data) {
		return await request('set_status_flag', data, 'post')
	},
	async testConnection(r) {
		return await request('test_connection', r, 'post')
	},
	async run(r) {
		return await request('run', r, 'post')
	},
	async queryTableDdl(r) {
		return await request('query_table_ddl', r, 'post')
	},
	async queryTableFieldList(r) {
		return await request('query_table_field_list', r, 'post')
	},
	async queryTableFieldModelList(r) {
		return await request('query_table_field_model_list', r, 'post')
	},
	async queryTableIndexList(r) {
		return await request('query_table_index_list', r, 'post')
	},
	async queryTableKeysList(r) {
		return await request('query_keys_list', r, 'post')
	},
	async queryTableList(r) {
		return await request('query_table_list', r, 'post')
	},
	async queryCatalogList(r) {
		return await request('query_catalog_list', r, 'post')
	},
	async querySchemaList(r) {
		return await request('query_schema_list', r, 'post')
	},
	async queryById(r) {
		return await request('get_by_id', r, 'post')
	},
	async addUpdateTable(r) {
		return await request('add_update_table', r, 'post')
	},
	async addUpdateIndex(r) {
		return await request('add_update_index', r, 'post')
	},
	async removeTable(r) {
		return await request('remove_table', r, 'post')
	},
	async queryCreateTableFieldList(r) {
		return await request('query_create_table_field_list', r, 'post')
	},
	async executeDdl(r) {
		return await request('execute_ddl', r, 'post')
	},
	async queryUpdateTableFieldList(r) {
		return await request('query_update_table_field_list', r, 'post')
	},
	async dropIndex(r){
		return await request('drop_index', r, 'post')
	}
}
